home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / Newswatcher 2.0b22 / NW Source / Source / about.c next >
Encoding:
C/C++ Source or Header  |  1994-07-18  |  3.4 KB  |  144 lines  |  [TEXT/MMCC]

  1. /*----------------------------------------------------------------------------
  2.  
  3.     about.c
  4.  
  5.     This module presents the about box.
  6.     
  7.     Copyright © 1994, Northwestern University.
  8.  
  9. ----------------------------------------------------------------------------*/
  10.  
  11. #include <stdio.h>
  12.  
  13. #include "glob.h"
  14. #include "about.h"
  15. #include "text.h"
  16. #include "drawutil.h"
  17. #include "strutil.h"
  18. #include "windutil.h"
  19. #include "resutil.h"
  20.  
  21.  
  22.  
  23. #define kAboutText             128        /* resource id of about box text 'TEXT' resource */
  24.  
  25. #define kEggID                129        /* resource id of Easter egg 'STR#' resource */
  26.  
  27. #define kBigIconPictColor    128        /* resource id of big icon color picture */
  28. #define kBigIconPictBW        129        /* resource id of big icon B&W picture */
  29. #define kLogoPictColor        130     /* resource id of logo color picture */
  30. #define kLogoPictBW            131     /* resource id of logo B&W picture */
  31.  
  32.  
  33.  
  34. static short gDrawEasterEgg = 0;
  35.  
  36.  
  37.  
  38. /*----------------------------------------------------------------------------
  39.     DrawPanel.
  40.     
  41.     Draw the panel area.
  42.     
  43.     Entry:    wind = pointer to about window.
  44. ----------------------------------------------------------------------------*/
  45.  
  46. static void DrawPanel (WindowPtr wind)
  47. {
  48.     Rect r;
  49.     CStr255 versStr;
  50.     Str255 str;
  51.     CStr255 fmt;
  52.     TextStyle savedStyle;
  53.     OSErr err = noErr;
  54.     Str255 egg;
  55.     
  56.     GetPortTextStyle(&savedStyle);
  57.     SetRect(&r, 50, 10, 134, 85);
  58.     DrawColorPict(kBigIconPictColor, kBigIconPictBW, &r);
  59.     SetRect(&r, 180, 17, 390, 56);
  60.     DrawColorPict(kLogoPictColor, kLogoPictBW, &r);
  61.  
  62.     err = GetVersionString((StringPtr)versStr);
  63.     p2cstr((StringPtr)versStr);
  64.     if (err != noErr) goto exit;
  65.     GetCString(kStrVersion, fmt);
  66.     sprintf((char*)str, fmt, versStr);
  67.     c2pstr((char*)str);
  68.     MoveTo(183, 70);
  69.     TextFont(systemFont);
  70.     TextSize(12);
  71.     DrawString(str);
  72.     if (gDrawEasterEgg > 0) {
  73.         MoveTo(183, 88);
  74.         TextFont(applFont);
  75.         TextSize(9);
  76.         TextFace(bold | italic);
  77.         GetIndString(egg, kEggID, gDrawEasterEgg);
  78.         if (*egg == 0) {
  79.             gDrawEasterEgg = 0;
  80.         } else {
  81.             DrawString(egg);
  82.         }
  83.     }
  84.     
  85. exit:
  86.  
  87.     SetPortTextStyle(&savedStyle);
  88. }
  89.  
  90.  
  91.  
  92. /*----------------------------------------------------------------------------
  93.     DoAboutNewsWatcher
  94.     
  95.     Present the about box.
  96.     
  97.     Exit:    function result = error code.
  98. ----------------------------------------------------------------------------*/
  99.  
  100. OSErr DoAboutNewsWatcher (void)
  101. {
  102.     Handle text;
  103.     Str255 title;
  104.     OSErr err = noErr;
  105.     WindowPtr wind;
  106.     
  107.     gDrawEasterEgg = 0;
  108.     GetPString(kStrAboutWindTitle, title);
  109.     if (CheckTextWindowAlreadyOpen(title)) return noErr;
  110.     err = MyGet1Resource('TEXT', kAboutText, &text);
  111.     if (err != noErr) return err;
  112.     err = MakeNewTextWindow(title, 100, DrawPanel, text, &wind);
  113.     MyReleaseResource(text);
  114.     return err;
  115. }
  116.  
  117.  
  118.  
  119. /*----------------------------------------------------------------------------
  120.     CheckAboutWindowEasterEgg
  121.     
  122.     Check for mouse down on big icon, display Easter egg.
  123.     
  124.     Entry:    wind = pointer to text window.
  125.             where = mouse down location, local coords.
  126.             modifiers = keyboard modifiers.
  127. ----------------------------------------------------------------------------*/
  128.  
  129. void CheckAboutWindowEasterEgg (WindowPtr wind, Point where, short modifiers)
  130. {
  131.     Rect r;
  132.     Str255 title, windTitle;
  133.     
  134.     if ((modifiers & optionKey) == 0) return;
  135.     GetPString(kStrAboutWindTitle, title);
  136.     GetWTitle(wind, windTitle);
  137.     if (!EqualString(title, windTitle, false, false)) return;
  138.     SetRect(&r, 50, 10, 134, 85);
  139.     if (!PtInRect(where, &r)) return;
  140.     gDrawEasterEgg++;
  141.     SetRect(&r, 180, 76, wind->portRect.right, 93);
  142.     InvalRect(&r);
  143. }
  144.